   /**
    * 日期格式化
   * @param {String}  
   * @returns String
   */ 
    function fnDate(d) {
        var d1 = new Date(d)
        var d2 = new Date()
        var seconds = ( d2.getTime() - d1.getTime() ) / 1000
        var minutes = seconds/60
        var hours = minutes/60
        var result = ''
        if (seconds<0) {
        result = '请勿输入将来的时间'
        } else if (seconds<60) {
        result = '刚刚'
        } else if (minutes>1 && minutes<60) {
        result = Math.floor(minutes) + '分钟前'
        } else if (hours>=1 && hours<24) {
        result = Math.floor(hours) + '小时前'
        } else {
        result = '请输入24小时以内的时间'
        }
        return result
        }
     
   /**
   * 补字符串中的0
   * @param {String|Number} data  
   * @returns 
   */
    function zeroize(data) {
    return String(data).length === 1 ? '0'+data : data
    } 
     
    /**
    * 快速获取当前时间
    * @param {String} str 
    * @returns String
    */
    function format(str)
    {
      var d = new Date()
      str = str.replaceAll('Y', d.getFullYear())
      str = str.replaceAll('m', zeroize(d.getMonth()+1)  )
      str = str.replaceAll('d', zeroize(d.getDate())     )
      str = str.replaceAll('H', zeroize(d.getHours())    )
      str = str.replaceAll('i', zeroize(d.getMinutes())  )
      str = str.replaceAll('s', zeroize(d.getSeconds())  )
      return str
    }
  /**
  * 随机变化颜色
  * @results String
  */
     
    function  randomcolor()
    { var arr = [0,1,2,3,4,5,6,7,8,9, 'A', 'B', 'C', 'D', 'E', 'F']
     var min=0
     var max=arr.length-1
     var one=arr[Math.floor(Math.random()*(max-min)+1+min)]
     var two=arr[Math.floor(Math.random()*(max-min)+1+min)]
     var three=arr[Math.floor(Math.random()*(max-min)+1+min)]
     var four=arr[Math.floor(Math.random()*(max-min)+1+min)]
     var five=arr[Math.floor(Math.random()*(max-min)+1+min)]
     var six=arr[Math.floor(Math.random()*(max-min)+1+min)]
     return '#'+one+two+three+four+five+six
     }
        /**
        * 判断浏览器
        */
        function  nav(){
          if (navigator.userAgent.indexOf('Chrome') !== -1)
          {
            return "谷歌浏览器"
          }
          
          if (navigator.userAgent.indexOf('Firefox') !== -1)
          {
            return "火狐浏览器"
          }
          if (navigator.userAgent.indexOf('Trident') !== -1)
          {
            return "IE浏览器"
          }
          if (navigator.userAgent.indexOf('Safari') !== -1)
          {
            return "苹果浏览器"
          }
          if (navigator.userAgent.indexOf('Opera') !== -1)
          {
            return "Opera浏览器"
          }
         }
     
         /**
          * PC还是移动
          * @returns String
          */
          function pc() {
          var webTemp = window.navigator.userAgent
          var temp = ['phone','pad','pod','iPhone','iPod','ios','iPad','Android','Mobile',
           'BlackBerry','IEMobile','MQQBrowser','JUC','Fennec','wOSBrowser',
           'BrowserNG','WebOS','Symbian','Phone']
           for(var i = 0;i < temp.length;i++){
           if(webTemp.indexOf(temp[i]) != -1){
           return('移动端')
           }else{
           return('PC端')
           }
           }
           } 
     
     
         /**
         *  判断是否是微信浏览器
         * @param {Boolean} str  true/false
         * @returns 是/不是微信浏览器
         */
          function WeChat() {
           var weChat = ''
           var ua = navigator.userAgent.toLowerCase();
           if (ua.match(/MicroMessenger/i) == 'micromessenger') {
               weChat = '是微信浏览器'
           } else {
               weChat = '不是微信浏览器'
           }
           return weChat
       }
     
     
       /**
      * 获取标签非行内样式
      * @returns String
      */
     function getStyle(tagObj,cssAttr){
       if(window.getComputedStyle) {
           return getComputedStyle(tagObj)[cssAttr] 
       } else {
           return tagObj.currentStyle[cssAttr]
       }
     }
  
/**
 * 获取地址栏上的参数
 * @param {string} key 
 * @returns 
 */
function getParams(key){
  let quary=decodeURI(location.search.substring(1))//保存起了参数
  let vars=quary.split("&")
  for(var i=0;i<vars.length;i++){
    var tempArr=vars[i].split("=")
    if(tempArr[0] == key)
    return tempArr[1]

  }
  return false//终止函数继续执行
}




     